//
//  Adpator.KeyWindow.swift
//  Adapt
//
//  Created by Flutter on 2021/7/7.
//

import UIKit

public extension Adaptor { enum KeyWindow {} }

public extension Adaptor.KeyWindow {
    static let current: UIWindow = {
        if #available(iOS 13.0,*) {
            guard let keyWindow = UIApplication.shared.windows.filter({$0.isKeyWindow}).first else { fatalError("key window not found") }
            return keyWindow
        } else {
            guard let keyWindow = UIApplication.shared.keyWindow else { fatalError("key window not found") }
            return keyWindow
        }
    }()
}

public extension Adaptor.KeyWindow {
    static let safeAreaTop = current.safeAreaInsets.top
    static let safeAreaBottom = current.safeAreaInsets.bottom
}
